var newboardpaikeCheckedItems;
var data_data;
function getnewboardpaikeData() {
    
    
    
	var startDate = $("#newboardpaikeStartDate").val();
	var endDate = $("#newboardpaikeEndDate").val();
    
    
    
   

	$(".newboardpaikeChart").html("");
	if (startDate != "" && endDate != "")
	{
		var start = new Date();
		var end = new Date();

		//统计项
		var items = document.getElementsByName("newboardpaikeCheckbox");
		newboardpaikeCheckedItems = new Array();
		for(var i=0;i<items.length;i++) {
			if (items[i].checked)
			{
				newboardpaikeCheckedItems.push(items[i].value);
			}
		}

		if(newboardpaikeCheckedItems.length > 0) {


			jQuery('#body-wrapper').showLoading();
			start.setFullYear(startDate.substring(0,4), startDate.substring(5,7)-1, startDate.substring(8,10));
			end.setFullYear(endDate.substring(0,4), endDate.substring(5,7)-1 ,endDate.substring(8,10));

			days = parseInt((end - start)/1000/60/60/24)+1;

			var APIurl = "/client/newboardpaike?staDate="+startDate+"&pd="+days;
	        
            
            

			
			$.ajax({
				type: "GET",
				url: APIurl,
				dataType : "json",
				jsonnp: "callback",
				success:function(data,textStatus){ loadnewboardpaikeData(data)}
			});
		}
		else {
			alert("请选择至少一个统计项");
		}

	}
	else {
		alert("请选择时间区域");
	}
}


var newboardpaikeTabArr, newboardpaikeDetailArr, newboardpaikeSumArr, newboardpaikeDateArr, MainSubTitle;
function loadnewboardpaikeData(data) {
    
   
    
    data_data = data;
	var tab = "";
	var startDate = $("#newboardpaikeStartDate").val();
	var endDate = $("#newboardpaikeEndDate").val();
	MainSubTitle = startDate.replace(/\//g, "-") + " 至 " + endDate.replace(/\//g, "-");
	jQuery('#body-wrapper').hideLoading();	


	newboardpaikeTabArr = new Array();
	newboardpaikeDetailArr = new Array();
	newboardpaikeSumArr = new Array();
	newboardpaikeDateArr = new Array();
    
    

            genTabsnewboardpaike("newboardpaike");
            
            //读取数据
            
        if ($("#newboardpaikePieTab").hasClass("selbitem")){
            
			changeChartType('newboardpaike', 'Pie');
        }
        
        if ($("#newboardpaikeTableTab").hasClass("selbitem")){
            
			changeChartType('newboardpaike','Table');
        }
        
        if (!$("#newboardpaikeTableTab").hasClass("selbitem") && !$("#newboardpaikePieTab").hasClass("selbitem")){
            
			changeChartType('newboardpaike','Pie');
        }
        
        
        
        //生成表格
        genTop10Tablenewboard("newboardpaikeTable",data['Phone']['table1'],data['Phone']['table2'],data['Phone']['table3']);
        
        //生成线图
        genSummaryLineChart_newboard("newboardpaikePie","排名趋势图",data['Phone']['xianx'],data['Phone']['xiany'],data['Phone']['xianm']);
        
    
	
}

function changenewboardpaikeTab(tabName,optionName) {
	
        
    
        //生成表格
        genTop10Tablenewboard("newboardpaikeTable",data_data[tabName]['table1'],data_data[tabName]['table2'],data_data[tabName]['table3']);
        
        //生成线图
        genSummaryLineChart_newboard("newboardpaikePie","排名趋势图",data_data[tabName]['xianx'],data_data[tabName]['xiany'],data_data[tabName]['xianm']);
    
    
    
	//$(".bitem").removeClass("selbitem");
    $("#newboardpaikeTabPhone").removeClass("selbitem");
    $("#newboardpaikeTabPad").removeClass("selbitem");
	$("#newboardpaikeTab"+tabName).addClass("selbitem");	
    
    
    
	
}

function changenewboardpaikeTableTabcc(cc){
    
    
    $("#newboardpaikeTableTab1").removeClass("selbitem");
    $("#newboardpaikeTableTab2").removeClass("selbitem");
    $("#newboardpaikeTableTab"+cc).addClass("selbitem");
    
    
    $("#newboardpaikeTableX1").hide();
    $("#newboardpaikeTableX2").hide();
    
    $("#newboardpaikeTableX"+cc).show();

}



